package com.zhouxiaoxuan13.consumer.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 促销实体DTO
 * 用于Feign客户端调用时的数据传输
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Promotion {

    private Long id;
    private String name;
    private String description;
    
    // 关联的生鲜商品ID
    private Long freshProductId;
    
    // 促销价格
    private BigDecimal promotionPrice;
    
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
    private LocalDateTime startDate;
    
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
    private LocalDateTime endDate;
    
    private boolean active = true;
    
    // 创建时间
    private LocalDateTime createdTime;
    
    // 更新时间
    private LocalDateTime updatedTime;
    
    /**
     * 判断促销是否当前有效
     */
    public boolean isCurrentlyActive() {
        LocalDateTime now = LocalDateTime.now();
        return active && !now.isBefore(startDate) && !now.isAfter(endDate);
    }
}
